#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main() 
{
    umask(0);
    int fd = open("log.txt", O_RDONLY); 
    if (fd < 0) 
    {
        perror("open");
        return 1;
    }
    printf("open success, fd: %d\n", fd);
    char buffer[64];
    memset(buffer, '0', sizeof(buffer)); 
    read(fd, buffer, sizeof(buffer)); 
    printf("%s", buffer); // 输出读取的内容
    close(fd);
    return 0;
}
